<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="author" content="" />
<link rel="stylesheet" href="../css/main.css" type="text/css" />
<link rel="stylesheet" href="../css/themes/default.css" type="text/css"/>
<link rel="stylesheet" href="../css/themes/mac_os_x.css" type="text/css"/>
<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript" src="../js/scriptaculous.js"></script>
<script type="text/javascript" src="../js/controls.js"></script>
<script type="text/javascript" src="../js/window.js"></script>
<script type="text/javascript" src="../js/window_effects.js"></script>
<script type="text/javascript" src="../js/page.js"></script>
<script type="text/javascript">
/*
 * is already there the new year?
 */
var count_year = <?php print $count ?>;

var cdc_created = <?php print $exist_cdc ?>;
var reg_created = <?php print $exist_reg ?>;
var schedule_created = <?php print $exist_sch ?>;
var scr_created = <?=$count_data ?>;

function crea_cdc(){
	if(cdc_created){
		alert("I consigli di classe sono gia' presenti in archivio");
		return false;
	}
	var url = "<?php print $_SESSION['__config__']['root_site'] ?>admin/crea_cdc.php";
	
    req = new Ajax.Request(url,
			  {
			    	method:'post',
			    	onSuccess: function(transport){
			    		var response = transport.responseText || "no response text";
			    		dati = response.split(";");
			    		if(dati[0] == "ko"){
			    			alert("Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2]);
			    			return;
			    		}
			    		else{
							alert("Operazione conclusa con successo");
			    		}
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore..."); }
			  });
}

function crea_orario(){
	if(schedule_created){
		alert("Tabella orario gia' popolata");
		return false;
	}
	var url = "<?php print $_SESSION['__config__']['root_site'] ?>admin/popola_tabella_orario.php";
	
    req = new Ajax.Request(url,
			  {
			    	method:'post',
			    	onSuccess: function(transport){
			    		var response = transport.responseText || "no response text";
			    		dati = response.split(";");
			    		if(dati[0] == "ko"){
			    			alert("Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2]);
			    			return;
			    		}
			    		else{
							alert("Operazione conclusa con successo");
			    		}
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore..."); }
			  });
}

var new_year = function(){
	today = new Date();
	y = today.getFullYear();
	if(today < (new Date(y, 5, 20)) || today > (new Date(y, 8, 15))){
		alert("La funzione di creazione nuovo anno sara' disponibile a partire dal giorno 21/06/"+y);
		return false;
	}
	else if(count_year > 0){
		alert("L'anno e' gia' presente in archivio");
		return false;
	}
	document.location.href = "new_year.php";
};

var crea_registro = function(){
	if(reg_created){
		alert("Il registro e' gia' stato creato");
		return false;
	}
	document.location.href = "registro.php";
};

var tm = 0;
var complete = false;
var timer;
var pop_scrutini = function(){
	leftS = (screen.width - 200) / 2;
	$('wait_label').style.left = leftS+"px";
	$('wait_label').style.top = "300px";
	$('overlay').show();
	if(scr_created > 0){	
		$('wait_label').innerHTML = "Dati già inseriti";
		$('wait_label').show();
		setTimeout("$('wait_label').fade({duration: 2.0})", 2000);
		setTimeout("$('overlay').hide()", 3800);
		//return;
	}
	else{
		var url = "popola_tabella_scrutini.php";
		$('wait_label').appear({duration: 0.8});
		req = new Ajax.Request(url,
				  {
				    	method:'post',
				    	onSuccess: function(transport){
					    	complete = true;
					    	clearTimeout(timer);
				    		var response = transport.responseText || "no response text";
				    		dati = response.split("#");
				    		//$('wait_label').style.display = "none";
				    		if(dati[0] == "ko"){
				    			$('wait_label').innerHTML = "Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2];
								setTimeout("$('wait_label').fade({duration: 2.0})", 2000);
								setTimeout("$('overlay').hide()", 3800);
				    			//alert("Errore SQL. \nQuery: "+dati[1]+"\nErrore: "+dati[2]);
				    			return;
				    		}
				    		else{
								$('wait_label').innerHTML = "Operazione conclusa";
								setTimeout("$('wait_label').fade({duration: 2.0})", 2000);
								setTimeout("$('overlay').hide()", 3800);
								
				    		}
				    	},
				    	onFailure: function(){ alert("Si e' verificato un errore..."); }
				  });
		upd_str();
	}
};

var upd_str = function(){
	tm++;
	//alert(tm);
	if(tm > 5){ 
		tm = 0;
		$('wait_label').innerHTML = "Caricamento in corso";
	}
	else
		$('wait_label').innerHTML += ".";
	timer = setTimeout("upd_str()", 1000);
};

var _hide = function(){
	$('overlay').hide();
	$('wait_label').hide();
};

</script>
<style>
#wait_label{
	width: 200px;
	height: 40px;
	text-align: center;
	background-color: #000000; 
	border: 1px solid #CCCCCC; 
	border-radius: 8px 8px 8px 8px;
	color: white;
	font-weight: bold;
	vertical-align: middle;
}
</style>
<title>Registro elettronico</title>
</head>
<body>
	<div id="header">
		<div class="wrap">
			<?php include "header.php" ?>
		</div>
	</div>
	<div class="wrap">
	<div id="main" style="background-color: #FFFFFF; padding-bottom: 30px; width: 100%">
        <table width="90%" style="margin-right: auto; margin-left: auto">
            <tr>
                <td style="font-weight: bold; font-size: 14px" colspan="2" align="center">Gestione registro elettronico</td>
            </tr>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7; ">Notizie, comunicazioni, attivit&agrave;</td>
            </tr>
            <tr>
                <td style=" width: 30%"><a href="adm_news/news.php">News</a></td>
                <td style="color: #003366">
                    <a href="adm_news/news.php">Gestisci le news, inserisci le novit&agrave; del sito o correggi quelle presenti...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_events/events.php">Eventi</a></td>
                <td style="color: #003366;">
                    <a href="adm_events/events.php">Gestisci il calendario delle attivit&agrave;: collegi, colloqui, consigli...</a>
                </td>
            </tr>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7">Gestione utenti</td>
            </tr>
             <tr>
                <td style="width: 30%"><a href="adm_users/users.php">Utenti</a></td>
                <td style="color: #003366">
                    <a href="adm_users/users.php">Inserisci nuovi utenti, modifica i dati di quelli gi&agrave; presenti e cancellali dal db...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_users/teachers.php">Docenti</a></td>
                <td style="color: #003366">
                    <a href="adm_users/teachers.php">Gestisci i dati dei docenti...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_students/alunni.php">Alunni</a></td>
                <td style="color: #003366">
                    <a href="adm_students/alunni.php">Gestisci i dati degli alunni</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_parents/genitori.php">Genitori</a></td>
                <td style="color: #003366">
                    <a href="adm_parents/genitori.php">Gestisce i dati dei genitori e le associazioni con gli alunni...</a>
                </td>
            </tr>
              <tr>
                <td style="width: 30%"><a href="new_pwd.php">Modifica password utente</a></td>
                <td style="color: #003366">
                    <a href="new_pwd.php">Modifica la password di un utente a scelta...</a>
                </td>
            </tr>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7">Gestione classi</td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_classes/classi.php">Classi</a></td>
                <td style="color: #003366">
                    <a href="adm_classes/classi.php">Crea e modifica classi, consigli di classe...</a>
                </td>
            </tr>
            <?php if($_SESSION['__user__']->getUid() == 1){ ?>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7">Gestione statistiche</td>
            </tr>
            
            <tr>
                <td style="width: 30%"><a href="viste.php">Crea viste </a></td>
                <td style="color: #003366">
                    <a href="viste.php">Crea le viste utilizzate per le statistiche...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="statistiche.php">Crea statistiche</a></td>
                <td style="color: #003366">
                    <a href="statistiche.php">Crea i file xml contenenti i dati statistici...</a>
                </td>
            </tr>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7">Gestione nuovo anno</td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="new_year()">Crea il nuovo anno </a></td>
                <td style="color: #003366">
                    <a href="#" onclick="new_year()">Crea il record relativo al nuovo anno scolastico...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="inserisci_alunni.php">Inserisci alunni </a></td>
                <td style="color: #003366">
                    <a href="inserisci_alunni.php">Batch per inserire gli alunni dal file Argo...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="create_account('student', 1)">Account alunni</a></td>
                <td style="color: #003366">
                    <a href="#" onclick="create_account('student', 1)">Crea e gestisce in automatico i dati di account per gli alunni attivi...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="crea_orario()">Orario</a></td>
                <td style="color: #003366">
                    <a href="#" onclick="crea_orario()">Popola la tabella orario del db</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="crea_cdc()">Crea i record CDC</a></td>
                <td style="color: #003366">
                    <a href="#" onclick="crea_cdc()">Crea i record necessari per popolare la tabella dei cdc...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="crea_registro()">Registro di classe </a></td>
                <td style="color: #003366">
                    <a href="#" onclick="crea_registro()">Crea i record del registro di classe...</a>
                </td>
            </tr>
            <?php } ?>
            <tr>
            	<td colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" style="padding-top: 5px; padding-bottom: 5px; text-align: center; font-weight: bold; background-color: #E7E7E7">Varie</td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="new_year.php?do=update">Anno in corso</a></td>
                <td style="color: #003366">
                    <a href="new_year.php?do=update">Modifica l'anno in corso: vacanze, date di inizio e fine lezioni, data di termine quadrimenstre ...</a>
                </td>
            </tr>        
            <tr>
                <td style="width: 30%"><a href="adm_workflow/index.php">Workflow</a></td>
                <td style="color: #003366">
                    <a href="adm_workflow/index.php">Gestisce tutto ci&ograve; che riguarda i processi di workflow relativi alle richieste ...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_projects/progetti.php">Progetti</a></td>
                <td style="color: #003366">
                    <a href="adm_projects/progetti.php">Gestisci i progetti della scuola</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_docs/index.php">Documenti</a></td>
                <td style="color: #003366">
                    <a href="adm_docs/index.php">Gestisce i documenti prodotti dalla scuola...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="#" onclick="pop_scrutini()">Scrutini</a></td>
                <td style="color: #003366">
                    <a href="#" onclick="pop_scrutini()">Carica i dati per gli scrutini...</a>
                </td>
            </tr>
            <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="<?php print $_SESSION['__config__']['root_site'] ?>">Torna all'Home Page</a></td>
                <td style="color: #003366">
                    <a href="<?php print $_SESSION['__config__']['root_site'] ?>">Senza commento...</a>
                </td>
            </tr>
            <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <!-- 
            <tr style="background-color: #E7E7E7">
                <td style="width: 30%"><a href="adm_mail/mail_to_user.php">Invio mail</a></td>
                <td style="color: #003366; background-color: #E7E7E7">
                    <a href="adm_mail/mail_to_user.php">Invia una mail ad un utente...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_newsletter/newsletter.php">Invio newsletter</a></td>
                <td style="color: #003366">
                    <a href="adm_newsletter/newsletter.php">Invia una mail usando la newsletter...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="config/home.php">Home Page</a></td>
                <td style="color: #003366">
                    <a href="config/home.php">Gestisci la struttura grafica della home page...</a>
                </td>
            </tr>
            <tr>
                <td style="background-color: #E7E7E7; width: 30%"><a href="config/frasi.php">Frasi famose</a></td>
                <td style="color: #003366; background-color: #E7E7E7">
                    <a href="config/frasi.php">Gestisci le frasi famose: aggiungi, modifica, cancella...</a>
                </td>
            </tr>
            <tr>
                <td style="width: 30%"><a href="adm_links/links.php">Links</a></td>
                <td style="color: #003366">
                    <a href="adm_links/links.php">Inserisci e gestisci i collegamenti a risorse esterne...</a>
                </td>
            </tr>
             -->
        </table>
    </div>
    <div id="overlay" style="display: none">
        <div id="wait_label" style="position: absolute; display: none; padding-top: 25px">Caricamento dati in corso</div>
    </div>
	<div id="footer">
		<p>Design: Luka Cvrk - <a href="http://www.solucija.com" title="Free Web Templates">Solucija</a></p>
	</div>
	</div>		
</body>
</html>